package com.survey.project.research.service.impl;

import java.util.List;

import com.survey.common.utils.DateUtils;
import com.survey.project.research.domain.QuestionChoice;
import com.survey.project.research.mapper.QuestionChoiceMapper;
import com.survey.project.research.service.IQuestionChoiceService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 问题选项Service业务层处理
 *
 * @author survey
 * @date 2021-05-26
 */
@RequiredArgsConstructor
@Service
public class QuestionChoiceServiceImpl implements IQuestionChoiceService {

    private final QuestionChoiceMapper questionChoiceMapper;

    /**
     * 查询问题选项
     *
     * @param choiceId 问题选项ID
     * @return 问题选项
     */
    @Override
    public QuestionChoice selectQuestionChoiceById(Long choiceId) {
        return questionChoiceMapper.selectQuestionChoiceById(choiceId);
    }

    /**
     * 查询问题选项列表
     *
     * @param questionChoice 问题选项
     * @return 问题选项
     */
    @Override
    public List<QuestionChoice> selectQuestionChoiceList(QuestionChoice questionChoice) {
        return questionChoiceMapper.selectQuestionChoiceList(questionChoice);
    }

    /**
     * 新增问题选项
     *
     * @param questionChoice 问题选项
     * @return 结果
     */
    @Override
    public int insertQuestionChoice(QuestionChoice questionChoice) {
        questionChoice.setCreateTime(DateUtils.getNowDate());
        return questionChoiceMapper.insertQuestionChoice(questionChoice);
    }

    /**
     * 修改问题选项
     *
     * @param questionChoice 问题选项
     * @return 结果
     */
    @Override
    public int updateQuestionChoice(QuestionChoice questionChoice) {
        questionChoice.setUpdateTime(DateUtils.getNowDate());
        return questionChoiceMapper.updateQuestionChoice(questionChoice);
    }

    /**
     * 批量删除问题选项
     *
     * @param choiceIds 需要删除的问题选项ID
     * @return 结果
     */
    @Override
    public int deleteQuestionChoiceByIds(Long[] choiceIds) {
        return questionChoiceMapper.deleteQuestionChoiceByIds(choiceIds);
    }

    /**
     * 删除问题选项信息
     *
     * @param choiceId 问题选项ID
     * @return 结果
     */
    @Override
    public int deleteQuestionChoiceById(Long choiceId) {
        return questionChoiceMapper.deleteQuestionChoiceById(choiceId);
    }
}
